package com.xiezc.fetch.consumer;

import com.xiezc.common.entity.BookInfo;
import com.xiezc.common.entity.Chapter;
import com.xiezc.common.entity.ChapterText;
import com.xiezc.common.result.BaseResult;
import com.xiezc.common.result.ListResult;
import com.xiezc.common.result.PageResult;
import com.xiezc.common.result.PojoResult;
import com.xiezc.fetch.config.FeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * feign的接口调用方式 与 retrofit 十分相似，.
 */
@FeignClient(name = "data-service", configuration = FeignConfiguration.class)
public interface SchedualDaoService {


    @RequestMapping(value = "/bookInfo/add", method = RequestMethod.POST)
    BaseResult addBookInfo(@RequestBody BookInfo bookInfo);

    @RequestMapping(value = "/bookInfo/getAllUrls", method = RequestMethod.GET)
    ListResult<String> getAllBookInfoUrls();

    @RequestMapping(value = "/bookInfo/getById", method = RequestMethod.GET)
    PojoResult<BookInfo> getById(@RequestParam("id") Integer id);

    @RequestMapping(value = "/bookInfo/getPageBookInfo", method = RequestMethod.GET)
    PageResult<BookInfo> getPageBookInfo(@RequestParam("current") Integer current, @RequestParam("size") Integer size);

    @RequestMapping(value = "/bookInfo/getByUrl", method = RequestMethod.GET)
    PojoResult<BookInfo> getBookInfoByUrl(@RequestParam("url") String url);


    @RequestMapping(value = "/chapter/getAllByBookId", method = RequestMethod.GET)
    ListResult<String> getAllByBookId(@RequestParam("bookId") Integer id);

    @RequestMapping(value = "/chapter/add", method = RequestMethod.POST)
    PojoResult<Integer> addChapter(@RequestBody Chapter chapter);

    @RequestMapping(value = "/chapter/getByUrl", method = RequestMethod.GET)
    PojoResult<Chapter> getChapterByUrl(@RequestParam("url") String url);

    @RequestMapping(value = "/chapterText/add", method = RequestMethod.POST)
    BaseResult addChapterText(@RequestBody ChapterText chapterText);

    @RequestMapping(value = "/chapterText/getByUrl", method = RequestMethod.GET)
    PojoResult<ChapterText> getChapterTextByUrl(@RequestParam("url") String url);
}